package com.yang.frost.blueberry.controller;

import com.alibaba.fastjson.JSONObject;
import com.yang.frost.blueberry.config.annotation.Log;
import com.yang.frost.blueberry.util.ApiResult;
import com.yang.frost.blueberry.weixin.params.WxTagsParams;
import com.yang.frost.blueberry.weixin.service.WxUmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 10296
 * @date 2021/4/14
 * @Description: 用户管理
 */
@RestController
@RequestMapping("/wxUmsApi")
@Api(value = "微信公众号用户管理API", tags = {"微信公众号用户管理"})
public class WxUmsController {

    private Logger logger = LoggerFactory.getLogger(WxUmsController.class);
    @Autowired
    private WxUmsService umsService;


    @Log("微信公众号-->标签管理-->创建标签")
    @PostMapping("/createTags")
    @ApiOperation(value = "微信公众号-->标签管理-->创建标签", notes = "微信公众号-->标签管理-->创建标签")
    public ApiResult createTags(WxTagsParams params, HttpServletResponse response) {
        JSONObject tags = new JSONObject();
        try {
            tags = umsService.createTags(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->标签管理-->获取创建的标签")
    @PostMapping("/getTags")
    @ApiOperation(value = "微信公众号-->标签管理-->获取创建的标签", notes = "微信公众号-->标签管理-->获取创建的标签")
    public ApiResult getTags(HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.getTags();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->标签管理-->编辑标签")
    @PostMapping("/updateTags")
    @ApiOperation(value = "微信公众号-->标签管理-->编辑标签", notes = "微信公众号-->标签管理-->编辑标签")
    public ApiResult updateTags(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.updateTags(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }


    @Log("微信公众号-->标签管理-->删除标签")
    @PostMapping("/deleteTags")
    @ApiOperation(value = "微信公众号-->标签管理-->删除标签", notes = "微信公众号-->标签管理-->删除标签")
    public ApiResult deleteTags(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.deleteTags(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->标签管理--> 获取标签下粉丝列表")
    @PostMapping("/getUserByTag")
    @ApiOperation(value = "微信公众号-->标签管理--> 获取标签下粉丝列表", notes = "微信公众号-->标签管理--> 获取标签下粉丝列表")
    public ApiResult getUserByTag(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.getUserByTag(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->用户管理-->批量为用户打标签")
    @PostMapping("/batchTaggingMembersTags")
    @ApiOperation(value = "微信公众号-->用户管理-->批量为用户打标签", notes = "微信公众号-->用户管理-->批量为用户打标签")
    public ApiResult batchTaggingMembersTags(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.batchTaggingMembersTags(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->标签管理-->批量为用户取消标签")
    @PostMapping("/batchuntaggingMembersTags")
    @ApiOperation(value = "微信公众号-->标签管理-->批量为用户取消标签", notes = "微信公众号-->标签管理-->批量为用户取消标签")
    public ApiResult batchUnTaggingMembersTags(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.batchUnTaggingMembersTags(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->标签管理-->获取用户身上的标签列表")
    @PostMapping("/getIdListTags")
    @ApiOperation(value = "微信公众号-->标签管理-->获取用户身上的标签列表", notes = "微信公众号-->标签管理-->获取用户身上的标签列表")
    public ApiResult getIdListTags(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.getIdListTags(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->用户管理-->设置用户备注名")
    @PostMapping("/updateRemarkUserInfo")
    @ApiOperation(value = "微信公众号-->用户管理-->设置用户备注名", notes = "微信公众号-->用户管理-->设置用户备注名")
    public ApiResult updateRemarkUserInfo(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.updateRemarkUserInfo(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->用户管理-->获取用户基本信息")
    @PostMapping("/getUserInfo")
    @ApiOperation(value = "微信公众号-->用户管理-->获取用户基本信息", notes = "微信公众号-->用户管理-->获取用户基本信息")
    public ApiResult getUserInfo(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.getUserInfo(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->用户管理-->批量获取用户基本信息")
    @PostMapping("/batchGetUserInfo")
    @ApiOperation(value = "微信公众号-->用户管理-->批量获取用户基本信息", notes = "微信公众号-->用户管理-->批量获取用户基本信息")
    public ApiResult batchGetUserInfo(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.batchGetUserInfo(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->用户管理-->获取关注者列表")
    @PostMapping("/getUserList")
    @ApiOperation(value = "微信公众号-->用户管理-->获取关注者列表", notes = "微信公众号-->用户管理-->获取关注者列表")
    public ApiResult getUserList(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.getUserList(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->用户管理-->获取公众号的黑名单列表")
    @PostMapping("/getBlackList")
    @ApiOperation(value = "微信公众号-->用户管理-->获取公众号的黑名单列表", notes = "微信公众号-->用户管理-->获取公众号的黑名单列表")
    public ApiResult getBlackList(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.getBlackList(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->用户管理-->拉黑用户")
    @PostMapping("/batchBlacklist")
    @ApiOperation(value = "微信公众号-->用户管理-->拉黑用户", notes = "微信公众号-->用户管理-->拉黑用户")
    public ApiResult batchBlacklist(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.batchBlacklist(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }

    @Log("微信公众号-->用户管理-->取消拉黑用户")
    @PostMapping("/batchUnBlacklist")
    @ApiOperation(value = "微信公众号-->用户管理-->取消拉黑用户", notes = "微信公众号-->用户管理-->取消拉黑用户")
    public ApiResult batchUnBlacklist(WxTagsParams params, HttpServletResponse response) {
        Map<String, Object> tags = new HashMap<>();
        try {
            tags = umsService.batchUnBlacklist(params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ApiResult.ok(tags);
    }


}
